package etc

// 系统配置, 配置字段可参见yml注释
// viper内置了mapstructure, yml文件用"-"区分单词, 转为驼峰方便
type Configuration struct {
	AppDebug   bool        `mapstructure:"AppDebug" json:"AppDebug"`
	HttpServer *HttpServer `mapstructure:"HttpServer" json:"HttpServer"`
	Mysql      *Mysql      `mapstructure:"Mysql" json:"Mysql"`
	Redis      *Redis      `mapstructure:"Redis" json:"Redis"`
	Logger     *Logger     `mapstructure:"Logger" json:"Logger"`
}

type HttpServer struct {
	Env              string `mapstructure:"Env" json:"Env"`
	EndPort          int    `mapstructure:"EndPort" json:"EndPort"`
	AllowCrossDomain bool   `mapstructure:"AllowCrossDomain" json:"AllowCrossDomain"`
}

type Mysql struct {
	Host            string `mapstructure:"Host" json:"host"`
	Username        string `mapstructure:"UserName" json:"username"`
	Password        string `mapstructure:"Password" json:"password"`
	DBName          string `mapstructure:"DBName" json:"db_name"`
	Charset         string `mapstructure:"Charset" json:"charset"`
	MaxIdle         int    `mapstructure:"MaxIdle" json:"max_idle"`
	MaxOpen         int    `mapstructure:"MaxOpen" json:"max_open"`
	Loc             string `mapstructure:"Loc" json:"loc"`
	MultiStatements bool   `mapstructure:"MultiStatements" json:"multi_statements"`
	ParseTime       bool   `mapstructure:"ParseTime" json:"parse_time"`
}

type Redis struct {
	Addr        string `mapstructure:"Addr" json:"addr"`
	Password    string `mapstructure:"Password" json:"password"`
	MaxIdle     int    `mapstructure:"MaxIdle" json:"max_idle"`
	MaxActive   int    `mapstructure:"MaxActive" json:"max_active"`
	IdleTimeout int    `mapstructure:"IdleTimeout" json:"idle_timeout"`
	DB          int    `mapstructure:"DB" json:"db"`
}

type Logger struct {
	RootPath      string `mapstructure:"RootPath" json:"root_path"`
	TextFormat    string `mapstructure:"TextFormat" json:"text_format"`
	TimePrecision string `mapstructure:"TimePrecision" json:"time_precision"`
	MaxSize       int    `mapstructure:"MaxSize" json:"max_size"`
	MaxBackups    int    `mapstructure:"MaxBackups" json:"max_backups"`
	MaxAge        int    `mapstructure:"MaxAge" json:"max_age"`
	Compress      bool   `mapstructure:"Compress" json:"compress"`
}
